#ifndef STRUCTUREWIDGET_H
#define STRUCTUREWIDGET_H

#include <QScrollArea>
#include "common.h"
#include <QMap>
//#include <QTableWidgetItem>


class QLabel;
class QToolBox;
class QTableWidget;
class QTableView;
class QStandardItemModel;
class QTableWidgetItem;
class QTableView;
class StructureModel;

typedef struct ItemInfo
{
   bool used;
   QTableWidgetItem *item_name;
   int stid;

   ItemInfo()
   {
       stid = 0;
       used = false;
       item_name = NULL;
   }
}*PtrItemInfo;

class StructureWidget : public QScrollArea
{
friend class EditWidget;
    Q_OBJECT
public:
    explicit StructureWidget(QScrollArea *parent = nullptr);
    ~StructureWidget();

    void CreateStructure(QString, QString struct_show_item_name, QString);
    void ClearStructure();
    void AddData(QString file_name, QString random, QString name, int id);
    void ShowData(QString file_name);
    void delete_item(QString id);
    void DeleteStructureData(QString file_name);
    void DeleteMainWayStructureData(QString file_name);
    void SortShow(QVector<PtrItemInfo> vector);
    inline void SetFileName(QString file_name) {mFileName = file_name;}

public slots:
    void slt_select_item(QString, QString name);
    void on_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
    void ShowStructue(QString file_name);
signals:
   void  signal_list_to_graphics(QString, QString);

private:

    QWidget *subWidget;
    QToolBox *tool_box;
    QTableWidget *table_text;
    QString mFileName;

    QMap<QString, QMap<QString, PtrItemInfo>> map_data;//<xml名称，<id, >>

};

#endif // STRUCTUREWIDGET_H
